package com.example.cuckoofilterdemo.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
//import org.springframework.http.ResponseEntity;  // Spring 内置的响应封装
//import com.example.cuckoofilterdemo.common.Result;

// 全局异常处理器中使用
@RestControllerAdvice
public class GlobalExceptionHandler {
    @ExceptionHandler(Exception.class)
    public Result<String> handleException(Exception e) {
        ErrorCode error = ErrorCode.INTERNAL_ERROR;
        return Result.fail(error.getCode(), error.getMsg());
    }
}
